<template>
  <div>
    <el-row>
      <el-col :span="2">
        <el-button type="primary"
                   size="small" icon="el-icon-s-order" round @click="toLibrary">作业库
        </el-button>
      </el-col>
    </el-row>
    <el-row style="margin-top: 20px">
      <el-col :span="2">
        <div style="font-size: 14px;color: #a5a5a5">作业列表</div>
      </el-col>
    </el-row>
    <div v-for="(item,index) in workRecordList" :key="index">
      <el-row style="margin-top: 10px">
        <el-card shadow="hover" style="text-align: left">
          <el-row>
            <el-col :span="4" style="font-size: 18px">
              <span>{{ item.workName }}</span>
            </el-col>
          </el-row>
          <el-row style="margin-top: 15px">
            <el-col :span="6" style="color: cadetblue">
              <i class="el-icon-timer"></i>
              <span>开 始: {{ item.contentStartTime }}</span>
            </el-col>
          </el-row>
          <el-row style="margin-top: 10px">
            <el-col :span="6" style="color: cadetblue">
              <i class="el-icon-timer"></i>
              <span>结 束: {{ item.contentEndTime }}</span>
            </el-col>
            <el-col :span="2" :offset="14">
              <span style="font-size: 24px;font-weight: bolder">{{ item.current }}</span><span style="color: #a5a5a5"> / {{
                item.total
              }} 完成</span>
            </el-col>
            <el-col :span="2" style="text-align: center">
              <el-button type="danger" round size="small" @click="checkWork(item.recordIds)">批 阅</el-button>
            </el-col>
          </el-row>
        </el-card>
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  name: 'CourseWorkDetails',
  data () {
    return {
      courseId: undefined,
      workRecordList: [],
    }
  },
  methods: {
    toLibrary () {
      this.$router.push('/course/library')
    },
    checkWork (ids) {
      this.curIds = ids.split(',')
      this.$store.state.workIds = this.curIds
      this.$router.push('/course/markingWork')
    },
    init () {
      this.$http.get('/api/workRecord/workListForTeacher/' + this.courseId).then((res) => {
        this.workRecordList = res.data.result
      })
    },
  },
  created () {
    this.courseId = this.$store.state.course.courseId

    this.init()
  },
}
</script>

<style scoped>

</style>
